-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mobile): use efficient sync #8842
Conversation
Deploying immich with Cloudflare Pages
|
for (int i = 0;; i += chunkSize) { | ||
DateTime? lastCreationDate; | ||
String? lastId; | ||
for (;;) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while
loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's identical to while(true). I can change it but it does not really matter I'd say :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this a lot in embedded system code, not used to seeing it in higher level language 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally use this for loops when I break out using other means.
While(true).. I use for endless tasks. Like a server listening indefinitely until it's killed etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be rewritten to a do while
loop on the condition assets.length < chunkSize
? I think that's the only break condition I see here. I concur that while (true)
loops are odd and potentially dangerous. I also think for (;;)
is less readable. I did not know what it meant until I read some of the other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sadly, I can't put the break condition in the loop condition check: it would not even run the first pass of the loop - i can only to while(true) instead of for(;;). The loop has two break conditions that cannot be handled in the loop header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I could be more help, as I'm not tremendously familiar with the backup sync. But I'm happy to do any testing if you'd like me to, as well!
I would guess this is caused by this:
|
It seems some more server changes are required for stacked assets (my test instance probably had no stacked assets at the time...). I converted this PR back to a draft and will work on a new PR for the required server changes. |
71fc321
to
be7865b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @fyfrey I tested this again and found a problem with rendering memory lane. Here is the error message From my debugging, the API returned the correct data. Still, the call to get the asset from the database when building the model probably happened before the synchronization process finished, so it could not parse all data correctly, leading to the error. Or, similar to previous symptom, not all assets are fetched |
Thanks @alextran1502 ! I've pushed a new commit to fix the bug in the memory lane. We were just lucky it did not occur previously.. |
Hi @fyfrey, the change doesn't entirely fix the issue. I have multiple memories on a day but only the first memory gets rendered, so I checked the database. On |
Thank you for testing again @alextran1502 . Very interesting. I did not notice any sync discrepancy (asset count) with my initial server changes. In the newer fix PR (#9100) we changed it to use the common asset query builder. It turns out it is incompatible with the app with stacked assets as the app expects all assets individually while the server returns them in an array with of the parent asset. This is probably the same issue you encountered a while ago and reverted server refactoring changes in #7752. made another server PR to fix it: #9189 to test: run server with #9189 and mobile with this PR... or locally merge one into the other.. simply copy the few changes from #9189 into your local branch of this PR :) |
I tried again with #9189 on my prod (FOR SCIENCE!!) and I still see missing memories. Checking the database again, now I see 68000 assets are fetched on this PR while still 69000 assets on |
Something must still be different between the old and the new server query. The old method also fetched archived assets for partners, maybe this accounts for the difference. But memories should not show archived assets.... I'll take another look at the code, or better the generated SQL. Edit: |
follow-up for #8755
enable the use of the more efficient endpoints to perform sync operations.
only merge after #9189 has been in a release for 1-2 weeks.